package com.itany.shop.rowmapper;

import com.itany.shop.entity.Order;
import com.itany.shop.entity.User;
import com.itany.shop.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author MissChen
 * @date 2024年04月02日 14:10
 */
public class OrderRowMapper implements RowMapper<Order> {
    @Override
    public Order mapRow(ResultSet rs) throws SQLException {
        Order order=new Order();
        order.setId(rs.getInt("id"));
        order.setNo(rs.getString("no"));
        order.setPrice(rs.getDouble("price"));
        User user=new User();
        user.setId(rs.getInt("user_id"));
        order.setUser(user);
        return order;
    }
}
